Split icons to separate files for ESM tree-shaking#8
Merged
RaresAil merged 7 commits intoRaresAil:mainfrom Apr 12, 2026
Merged
Conversation
[IMP] Split rollup into CJS (one file) and ESM (split files)
There was a problem hiding this comment.
Pull request overview
This PR restructures the build output to enable ESM tree-shaking by splitting individual icon components into separate files, reducing bundle sizes from 1.11 MB to 440.2 KB when only specific icons are imported.
Changes:
- Modified Rollup configuration to generate separate files for each icon in the ESM build
- Added post-build processing to conditionally re-add strokeWidth parameter only to icons that use it
- Updated package.json with sideEffects field to support tree-shaking optimization
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| rollup.config.js | Reconfigured ESM output to use multiple entry points (one per icon file) instead of a single bundle |
| post-build-icons.js | Added logic to selectively restore strokeWidth parameter to icon components that reference it |
| templates/svg.js | Removed strokeWidth from default function parameters (restored conditionally in post-build) |
| package.json | Added glob dependency, sideEffects configuration, and changed yarn to npm in build script |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR splits up the icons into separate files in the ESM version of the build to allow for efficient tree-shaking when creating application bundles. Unused icons will be pruned from the final bundle dramatically reducing file size and loading time.
Before:
./node_modules/@raresail/react-ionicons/dist/esm/index.js (1.11 MB)
After:
./static/chunks/*.js (Count: 289)
Total size: 440.2 KB